unit Trackproperties;

interface

uses
    Winapi.Windows, System.Variants, System.SysUtils, Vcl.StdCtrls,Winapi.Messages, Vcl.Graphics, Forms,
    Dialogs, Vcl.Controls,System.Classes, Vcl.Buttons, ComCtrls;

type
    TTrackPropsForm = class(TForm)
        Label1: TLabel;
        divedit: TEdit;
        ClosedCB: TCheckBox;
    SelectButton: TSpeedButton;
    AddButton: TSpeedButton;
    InsertButton: TSpeedButton;
    BuildButton: TSpeedButton;
        procedure ClosedCBClick(Sender: TObject);
        procedure diveditChange(Sender: TObject);
        procedure diveditKeyPress(Sender: TObject; var Key: Char);
    procedure SelectButtonClick(Sender: TObject);
    procedure BuildButtonClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    private
         
    public
         
    end;

var
    TrackPropsForm: TTrackPropsForm;

implementation

uses main, NodeProperties;

{$R *.dfm}

procedure TTrackPropsForm.ClosedCBClick(Sender: TObject);
begin
    form1.track.Closed := ClosedCB.checked;
    form1.track.StructureChanged;
end;

procedure TTrackPropsForm.diveditChange(Sender: TObject);
begin
    if length(divedit.Text) > 0 then
        form1.Track.Divisions := strtoint(divedit.text);
    form1.track.StructureChanged;
end;

procedure TTrackPropsForm.diveditKeyPress(Sender: TObject; var Key: Char);
begin
    form1.diveditKeyPress(sender, key);
end;

procedure TTrackPropsForm.SelectButtonClick(Sender: TObject);
begin
    form1.toolmode := TToolmode(TSpeedButton(sender).tag);
    form1.stage := 0;
    form1.Track.Selected := NIL;
    case form1.toolmode of
        tmSelect:
            form1.Statusbar1.SimpleText := 'Select a node to edit';
        tmAdd:
            form1.Statusbar1.SimpleText := 'Click to add nodes';
        tmInsert:
            form1.Statusbar1.SimpleText := 'Select an insertion node';
    end;
end;

procedure TTrackPropsForm.BuildButtonClick(Sender: TObject);
begin
    SelectButton.Down:=true;
    SelectButtonClick(self);
    form1.BuildTrack;
end;

procedure TTrackPropsForm.FormShow(Sender: TObject);
begin
     divedit.Text:=inttostr(form1.track.divisions);
     ClosedCB.checked:=form1.track.closed;
end;

end.

